package com.bhs.sansonglogistics.ui.orderDispose;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;

import android.os.Bundle;
import android.widget.TextView;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.base.BaseActivity;
import com.bhs.sansonglogistics.base.BaseFragment;
import com.bhs.sansonglogistics.ui.home.FragmentAdapter;
import com.bhs.sansonglogistics.ui.quality.VoucherListFragment;
import com.bhs.sansonglogistics.view.SelectedFont2;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

import java.util.ArrayList;

/**
 * 异常订单详情
 */
public class AbnormalOrderDetailActivity extends BaseActivity {
    private TabLayout mTabLayout;
    private ViewPager2 mViewPage;
    @Override
    public int initLayout() {
        return R.layout.activity_abnormal_order_detail;
    }

    @Override
    public void initView() {
        TextView mTvTitle = findViewById(R.id.tv_title);
        mTvTitle.setText("详情");
        mTabLayout = findViewById(R.id.tabLayout);
        mViewPage = findViewById(R.id.view_page);
    }

    @Override
    public void initData() {
        mTabLayout.setTabMode(TabLayout.MODE_FIXED);
        //tab切换时候的字体设置
        mTabLayout.addOnTabSelectedListener(new SelectedFont2(mActivity));
        ArrayList<BaseFragment> fragments = new ArrayList<>();
        fragments.add(AbnormalOrderScheduleFragment.newInstance(getIntent().getExtras()));
        fragments.add(AbnormalOrderDetailFragment.newInstance(getIntent().getExtras()));


        mViewPage.setOffscreenPageLimit(fragments.size());
        mViewPage.setAdapter(new FragmentAdapter(this, fragments));
        new TabLayoutMediator(mTabLayout, mViewPage, new TabLayoutMediator.TabConfigurationStrategy() {
            @Override
            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                tab.setText(position == 0 ? "处理进度" : "订单详情");
            }
        }).attach();
    }
}